﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SdmxMl.Structure;
using SdmxMl.Common;
using SdmxMl.Manager;

namespace SdmxMl.Panels
{
    public partial class DlgEditReferenceType : Form
    {
        private RepresentationSchemeType _representation;
        
        public DlgEditReferenceType(RepresentationSchemeType r)
        {
            InitializeComponent();

            // Fill Types
            comboBoxType.Items.Clear();
            foreach (RepresentationSchemeTypeType o in Enum.GetValues(typeof(RepresentationSchemeTypeType)))
                comboBoxType.Items.Add(o.ToString());
            _representation = r;

            if (_representation != null)
                comboBoxType.SelectedIndex = (int)_representation.SchemeType;
        }

        private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_representation != null)
            {
                // Update ref type
                if (comboBoxType.SelectedIndex >= 0)
                    _representation.SchemeType = (RepresentationSchemeTypeType)Enum.Parse(typeof(RepresentationSchemeTypeType),
                       comboBoxType.Items[comboBoxType.SelectedIndex].ToString(), true);

                ucEditReference.AtrefactType = _representation.DetermineArtefactType();
                ucEditReference.ArtefactRef = _representation;
            }

        }

    }
}
